package com.ruoyi.mq;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class QueueSender {

    /** 第三方接入消息队列 **/
    public static final String THIRD_QUEUE = "third_message";
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public void sendMessage(String channel, String message) {
        redisTemplate.convertAndSend(channel, message);
    }
    public void sendMessage(String channel, QueueMessage message) {
        redisTemplate.convertAndSend(channel, JSONObject.toJSONString(message));
    }
}
